package dao.jpa;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import dao.OrcamentoDAO;
import entity.Orcamento;

@Repository
public class OrcamentoJpaDAO extends GenericJpaDAO<Orcamento> implements
	OrcamentoDAO, Serializable {

    private static final long serialVersionUID = -103013773105778419L;

    @SuppressWarnings("unchecked")
    @Override
    public List<Orcamento> listarOrcamentosNaData(Date data) {

	final Criteria criteria = criarCriteria();
	criteria.add(Restrictions.le("dataInicial", data));
	criteria.add(Restrictions.or(Restrictions.ge("dataFinal", data),
		Restrictions.isNull("dataFinal")));

	return criteria.list();
    }

}
